﻿using Sgr.Domain.Entities;

namespace Sgr.OmniMetrics.Domain
{
    /// <summary>
    ///  指标实体
    /// </summary>
    public class OmniMetricEntity : Entity<long>, IAggregateRoot, IOptimisticLock
    {
        /// <summary>
        /// 指标唯一标识
        /// </summary>
        public string MetricKey { get; set; } = string.Empty;

        /// <summary>
        /// 统计粒度
        /// </summary>
        public Granularity TimeGranularity { get; set; } = Granularity.Day;

        /// <summary>
        /// 统计时间点（对齐到粒度起始，如按天统计存2024-03-20 00:00:00）
        /// </summary>
        public DateTime TimeValueUtc { get; set; } = DateTime.UtcNow;

        /// <summary>
        /// 基础数值01（如总量、平均值等标量）
        /// </summary>
        public double BasicValue01 { get; set; } = 0;

        /// <summary>
        /// 基础数值01（如总量、平均值等标量）
        /// </summary>
        public double BasicValue02 { get; set; } = 0;

        /// <summary>
        /// 基础数值02（如总量、平均值等标量）
        /// </summary>
        public double BasicValue03 { get; set; } = 0;

        /// <summary>
        /// 扩展数值（强类型）
        /// </summary>
        public string ExtendedValues { get; set; } = string.Empty;

        /// <summary>
        /// 指标值更新时间
        /// </summary>
        public DateTime UpdateTimeUtc { get; set; } = DateTime.UtcNow;

        #region IOptimisticLock (乐观锁)

        /// <summary>
        /// 行版本
        /// </summary>
        public long RowVersion { get; set; }

        #endregion IOptimisticLock (乐观锁)
    }
}